<%@page import="java.io.* , java.util.*, java.sql.*, com.myapp.struts.dao.*, com.myapp.struts.beans.*"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html:html lang="true">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>AccountHead View</title>
        <link href="../../../../css/cms.css" rel="stylesheet" type="text/css"> 
        <link href="css/cms.css" rel="stylesheet" type="text/css">     
    </head>

    <body bgcolor="#D3F1D5">
        <table width="980" border="0" cellspacing="0" cellpadding="0" align="center">

            <tr>
                <td width="878" rowspan="12">

      <html:form action="ahcreate" method="post">
                        <%
            AcheadDao sd2 = new AcheadDao();
            System.out.println("calling maxvalue method");
            String code = sd2.maxValue();
            System.out.println("code." + code);

                        %>

                        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" style="border-right: #000000 1px solid;
                               border-top: #000000 1px solid; border-left: #000000 1px solid;  border-bottom: #000000 1px solid; font-size: 9pt; color: #000000; font-family: Arial;">
<tr>
                                <tH height="29" colspan="3" align="center">Enter Account Head Details</tH>
                            </tr>
                            <tr>
                                <td width="216" height="17" align="left"> Account Head Number </td>
                              <td width="274" ><html:text property="accountHeadNumber"  value="<%=code%>" size="40"/></td>
                              <td width="467" ><html:errors property="accountHeadNumber"/>&nbsp;</td>
                          </tr>
                            
                          <tr>
                            <td >Account Head Name</td>
                            <td><html:text property="accountHeadName" maxlength="50" size="40" /></td>
                            <td><html:errors property="accountHeadName"/></td>                            </tr>
                             <tr>
                             <td>Account Type</td>
                             <td>           <html:select property="accountHeadType">
                                            <html:option value=""></html:option>
                                            <html:option value="cash">cash</html:option>
                                            <html:option value="bank">bank</html:option>
                                            <html:option value="other">other</html:option>
                                        </html:select>
                                    </td>
                                <td ><html:errors property="accountHeadType"/></td>                               
                            </tr>
                            <tr>
                                <td align="left">Schedule</td>
                                <td>                                    
                                    <html:select property="schedule" styleId="schedule">
                                        <html:option value=""></html:option>
                                        <%
            ScheduleDao shd = new ScheduleDao();

            ArrayList al = shd.listForAcHead();
            if (al != null) {
                Iterator itg = al.iterator();
                while (itg.hasNext() == true) {
                    ScheduleBean shb = (ScheduleBean) itg.next();
                    String schedule1=shb.getSub_Schedule1();
                    String schedule2=shb.getSub_Schedule2();
                    if (schedule1!=null && schedule2!=null)
                        {
                        System.out.println(" 1 and 2 not null");
                     %>
                    <html:option value="<%=schedule2%>"><%=schedule2%></html:option>
                    <%}
                    if (schedule1==null && schedule2!=null) {
                        System.out.println(" 2 not null");
                    %>
                        
                    <html:option value="<%=schedule2%>"><%=schedule2%></html:option>
               <%}
                    if (schedule1!=null && schedule2==null){
                        System.out.println(" 1 not null");
               %>
               <html:option value="<%=schedule1%>"><%=schedule1%></html:option>
               <%}
                    
                }
            }%>
                                </html:select>        </td>
                                <td><html:errors property="schedule"/></td>
                            </tr>
                            <tr>
                                <td align="left">Opening Balance </td>
                                <td ><html:text property="openingBalance" styleId="openingBalance" size="40" /><html:select property="balanceType">
                                        <html:option value="Cr">Cr</html:option>
                                        <html:option value="Dr">Dr</html:option>
                                </html:select>          </td>
                                <td ><html:errors property="openingBalance"/></td>
                            </tr>
                            <tr>
                                <td align="left" >Description</td>
                                <td><html:textarea property="description" styleId="description"/></td>
                                <td><html:errors property="description"/></td>
                            </tr>
                            <tr>
                                <td colspan="3" align="center" >
                                    <html:submit/>          &nbsp;&nbsp;&nbsp;&nbsp;
                                <html:reset/></td>
                            </tr>
                        </table>

                  </html:form>                                      
                  <p><br>
                    <br>
                      <br>
                        <br>
                          <br>
                            <br>
                              <br>
                  <iframe src="acheadView.jsp" width="100%" height="200"></iframe></p>
                   
              </td>
          </tr>
        </table>
    </body>
</html:html>
